package com.ask.controller.admin;

import com.ask.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import static com.ask.constant.RedisConstant.SHOP_STATUS_KEY;

@RestController("adminShopController")
@RequestMapping("/admin/shop")
public class ShopController {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @PutMapping("/{status}")
    public Result setStatus(@PathVariable Integer status) {
        stringRedisTemplate.opsForValue().set(SHOP_STATUS_KEY, status.toString());
        return Result.success();
    }

    // todo 解除注释
    @GetMapping("/status")
    public Result<Integer> getStatus() {
        return Result.success(1);
//        String statusStr = stringRedisTemplate.opsForValue().get(SHOP_STATUS_KEY);
//        Integer status = Integer.parseInt(statusStr);
//        return Result.success(status);
    }
}
